export default class Calendar {
  currentMonth: number;

  constructor() {
    this.currentMonth = new Date().getMonth() + 1
  }

  addZero(val: number) {
    return val < 10 ? '0' + val : `${val}`

  }

  getLastMonth(nth: number) {
    const currentMonth = this.currentMonth
    const diffval = currentMonth - nth
    if (diffval < 1) {
      return 12 + diffval

    } else {
      return diffval
    }
  }

  getNextNthMoenth(nth: number) {
    const currentMonth = this.currentMonth
    const sumval = currentMonth + nth
    if (sumval > 12) {
      return sumval - 12
    }
    return sumval
  }

  genetatarCalendarList() {
    return [
      this.addZero(this.getLastMonth(2)),
      this.addZero(this.getLastMonth(1)),
      this.addZero(this.currentMonth),
      this.addZero(this.getNextNthMoenth(1)),
      this.addZero(this.getNextNthMoenth(2)),
    ]
  }
}